import request from '@/utils/request'
import type { PostLoginPayload, ResApi, LoginRes, UserRes, User } from './user'

// 封装用户登录接口
export const loginApi = (data: PostLoginPayload) => {
  return request<ResApi<LoginRes>>({
    method: 'post',
    url: '/user/login',
    data,
  })
}

// 封装获取用户列表数据接口
export const getUserListApi = (params: any) => {
  return request<UserRes>({
    method: 'get',
    url: '/user/index',
    params,
  })
}

// 封装新增用户接口
export const addUserApi = (data: any) => {
  return request({
    method: 'post',
    url: '/user/create',
    data,
  })
}

// 封装删除用户接口
export const delUserApi = (params: any) => {
  return request({
    method: 'delete',
    url: '/user/delete',
    params,
  })
}

// 封装更新用户接口
export const updateUserApi = (data: any) => {
  return request({
    method: 'put',
    url: '/user/update',
    data,
  })
}
